<template>
    <div>
        <h1>管理员登录</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">用户名</td>
                    <td>
                        <input type="text" v-model="qureyInfo.username" />
                    </td>
                </tr>
                <tr>
                    <td align="right">密码</td>
                    <td>
                        <input type="password" v-model="qureyInfo.password" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="登录" class="btn btn-primary" @click="ok" />
                    </td>
                </tr>
            </tbody>

        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref, reactive, onMounted } from 'vue';
import moment from 'moment';
import { useRoute, useRouter } from 'vue-router';
const route = useRoute();
const router = useRouter();

let qureyInfo: any = reactive({
    username: "",
    password: ""
})

const ok = () => {
    if (qureyInfo.username == "") {
        alert("名称不能为空");
        return;
    }
    if (qureyInfo.password == "") {
        alert("密码不能为空");
        return;
    }
    axios({
        url: '/api/Ward/AdminLogin',
        method: 'get',
        params: qureyInfo,
    })
        .then(res => {
            if (res.data == -1) {
                alert("名称错误");
                return;
            }
            if (res.data == -2) {
                alert("密码错误");
                return;
            }
            else {
                alert("添加成功");
                router.push('/departmomentAdd')
                return;
            }
        })
        .catch(err => {

        })
}

</script>

<style scoped></style>